package com.yeskery.transfer.util;

/**
 * 时间工具类
 * @author shuangjiang.du
 * @date 2018-12-19 15:28
 * @version 1.0
 */
public class TimeUtils {

	public static String toUnitString(long seconds) {
		long minutes, hours;
		String secondStr = "second", minuteStr = "minute", hourStr = "hour";
		int unit = 60;
		if (seconds <= unit) {
			return seconds + " " + (seconds > 1 ? secondStr + "s" : secondStr);
		}
		minutes = seconds / unit;
		seconds = seconds % unit;
		if (minutes <= unit) {
			return minutes + " " + (minutes > 1 ? minuteStr + "s" : minuteStr)
					+ " " + seconds + " " + (seconds > 1 ? secondStr + "s" : secondStr);
		}
		hours = minutes / unit;
		minutes = minutes % unit;
		return hours + " " + (hours > 1 ? hourStr + "s" : hourStr) + " " + minutes + " "
				+ (minutes > 1 ? minuteStr + "s" : minuteStr) + " "
				+ seconds + " " + (seconds > 1 ? secondStr + "s" : secondStr);
	}
}
